﻿<?php
if (!isset($_SESSION["taikhoan"]))
	{
		header("Location: dbcl-dangnhap.php");
	}
	include "connect.php"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<script language="javascript">
	function emptyCheck()
	{
		if (document.f.nd.value != "")
			document.f.luu.disabled = false;
		else document.f.luu.disabled = true;
	}
</script>

<form name="f" method="post" action="" onsubmit="">
			<table width="500" align="center" border="0" style="border:1px solid #0066FF" cellspacing="0">
						
					  <tr> 
							<td height="30" colspan="2" align="center" bordercolor="#FFFFFF" background="image/bg_header.gif">
								<span style="font-size:24px; color:#FFFFFF; font-weight:bold;">Thêm Tiêu Chí mới</span></td>
					  </tr>
					  
					  <tr bordercolor="#FFFFFF" align="center"> 
						  <td  height="15" width="200" colspan="2"></td>
						 
					  </tr>
						<?php
						     $sql=mysql_query("select max(ma_tc) from `tieu chi`");
							 $s=mysql_fetch_row($sql);
							 $ma=$s[0];
							 $matc=$ma+1;
						?>
					  <tr bordercolor="#FFFFFF" align="center"> 
						  <td  height="30" style="font-size:18px" width="200">Mã Tiêu Chí:</td>
						 <td align="left"><input type="text" name="matc" readonly="" size="4" class="mau" value="<?php echo $matc ?>" /></td>
					  </tr>
					  
					  <tr bordercolor="#FFFFFF" align="center"> 
						  <td  height="30" style="font-size:18px"> Nội Dung </td>
						 <td align="left"><textarea name="nd" cols="30" rows="5" onkeyup="emptyCheck();"></textarea></td>
					  </tr>
					  
					  <tr bordercolor="#FFFFFF" align="center"> 
						  <td  height="15"  colspan="2"></td>
						 
					  </tr>
					  
					  <tr bordercolor="#FFFFFF">
						  <td  align="right" height="30"><input type="submit" value="Lưu Lại" name="luu" disabled="true" /></td>
						  <td align="center"><input type="reset" value="Làm Lại" name="huy" onclick="document.f.luu.disabled = true;" /></td>
					 </tr>
					 <tr bordercolor="#FFFFFF" align="center"> 
						  <td  height="15"  colspan="2"></td>
						 
					  </tr>
					
			</table>
</form>
<?php
           if(isset($_POST["luu"]))
				{
				          $matc=$_POST["matc"];
				          $nd=$_POST["nd"];
						  $sql=mysql_query("select max(ma_hknk) from `hocki nienkhoa`");
						  $s=mysql_fetch_row($sql);
						  $hknk=$s[0];
						  $kq=mysql_query(" insert into `tieu chi` values('$matc','$nd', 0)");
						   $kq=mysql_query(" insert into `tieuchi hocki` values('$matc','$hknk' )");
						  echo"<script type='text/javascript'>alert('Them Thanh Cong')</script>";
		                  echo'<meta http-equiv="refresh" content="0;URL=dbcl-capnhat.php?nav=cntc">';
						  
				}
 ?>		

</body>
</html>
